const app = getApp();
Component({
  
  data: {
    frameClass1:'iconlogo z1',//默认正面在上面
    frameClass2: 'iconlogo z2',
    iconlogo:app.globalData.iconlogo,
    selected: 0,
    color:app.globalData.defaultforecolor,
    selectedColor:app.globalData.defaultmenucolor,
    defaultitlecolor:"#fffff",
    staticUrl:app.globalData.staticUrl,
    selected: 0,
    color: "#fff",
    selectedColor: "#176a54",
    list: [{
      
      pagePath: "/pages/newindex/index",
      iconPath: "/images/icon_component.png",
      selectedIconPath: "/images/icon_component_HL.png",
      text: "首页"
    }, {
      
      pagePath: "/pages/Schedul/index",
      iconPath: "/images/icon_schedule.png",
      selectedIconPath: "/images/icon_schedule_HL.png",
      text: "赛程"
    }, {
        
        pagePath: "/pages/Ranking/index",
        iconPath: "",
        selectedIconPath: "",
        text:""
    },
    {
       
        pagePath: "/pages/Ranking/index",
        iconPath: "/images/icon_ranking.png",
        selectedIconPath: "/images/icon_ranking_HL.png",
        text: "晋级"
      },
      {
       
        pagePath: "/pages/More/index",
        iconPath: "/images/icon_my.png",
        selectedIconPath: "/images/icon_my_HL.png",
        text: "我的"
      }],
      actionSheet: [   
        //{ name: '我的参赛证', path: "/pages/More/entrycertificate/index" },
        { name: '个人信息', path: '/pages/More/information/information' },
       
    ]
  },
  attached() {
    var that = this;
    setInterval(function(){
       // console.log("rotateFn ... " + app.globalData.refreshtime );
        that.rotateFn();
    }, app.globalData.refreshtime)
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      this.setData({
        selected: data.index
      });
      wx.switchTab({url})
    },

    settabselected(e){
      this.data.selected = e;
      console.log(this.data.selected);
      
    },
    rotateFn: function (e) {
      var that = this
      if (this.data.frameClass1=='iconlogo z1'&&
        this.data.frameClass2=='iconlogo z2'){
        that.setData({
          frameClass1: "iconlogo front",
          frameClass2: "iconlogo back",
        })
        setTimeout(function () {
          that.setData({
            frameClass1: "iconlogo z2",
            frameClass2: "iconlogo z1",
          })
        }, 1000);
      }
      else{
        that.setData({
          frameClass1: "iconlogo back",
          frameClass2: "iconlogo front",
        })
        setTimeout(function () {
          that.setData({
            frameClass1: "iconlogo z1",
            frameClass2: "iconlogo z2",
          })
        }, 1000);
      }
    },
    openscoring:function() {
      wx.navigateTo({
        url: '/pages/scoring/scoring',
      })
  },
  actionRelease() {
    wx.showActionSheet({
        itemList: ['个人信息'], //和actionSheet对应
        success: (res) => {
            const url = this.data.actionSheet[res.tapIndex].path
            if (url) {
                wx.navigateTo({
                    url: url,
                    events: {
                        acceptDataFromOpenedPage: function(data) {
                            console.log(data)
                        },
                        someEvent: function(data) {
                            console.log(data)
                        }
                    },
                    success: (res) => {
                        res.eventChannel.emit('acceptDataFromOpenerPage', {
                            showPopup: true,
                        })
                    }
                })
            } else {
                wx.showToast({
                    title: '功能暂未开放，敬请期待',
                    icon: 'none'
                })
                return
            }
        },
        fail(res) {
            console.log(res.errMsg)
        }
    })
    this.rotateFn();
},
  }

 
})